import TvBoxInput from "../TvBox/TvBoxInput";
import MonoSingle from "./MonoSingle";

const { ccclass, property } = cc._decorator;

@ccclass
export default class LoadScene extends cc.Component {

    @property(cc.String)
    sceneName: string = "";


    start() {
        this.onClickEvent(this.node.getComponent(cc.Button), 'LoadScene', 'loadSceneEvent');
    }

    onClickEvent(btn: cc.Button, component: string, handler: string) {
        btn.clickEvents = [];
        var clickEventHandler = new cc.Component.EventHandler();
        clickEventHandler.target = btn.node;
        clickEventHandler.component = component;
        clickEventHandler.handler = handler;
        clickEventHandler.customEventData = '';
        btn.clickEvents.push(clickEventHandler);
    }

    loadSceneEvent(): void {
        MonoSingle.Reset();
        cc.director.loadScene(this.sceneName, function () {

            cc.error("切换场景完成")
        });
    }
}
